﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Webcar.BLL
{
    public class QuerySettings
    {
        public const string CarCostList = "CarCostList";
        public const string CarList = "CarList";
        public const string CarMileList = "CarMileList";
        public const string UserList = "UserList";
        public const string CarSendList = "CarSendList";
        public const string ContractList = "ContractList";
        public const string DriverList = "DriverList";
        public const string FileList = "FileList";
        public const string InsureList = "InsureList";
        public const string MailList = "MailList";
        public const string SendMailList = "SendMailList";
        public const string RepairList = "RepairList";
        public const string ReportList = "ReportList";
        public const string SecList = "SecList";
        public const string GpsList = "GpsList";
        public const string RunRecordList = "RunRecordList";
        public const string DeptList = "DeptList";
        public QuerySettings()
        {
            this.Columns = new List<QueryColumn>();
        }
        //public string UpdatePanelId
        //{
        //    get;
        //    set;
        //}
        //public string Controller
        //{
        //    get;
        //    set;
        //}
        public string QueryKey
        {
            get;
            set;
        }
        public List<QueryColumn> Columns
        {
            get;
            set;
        }
    }

    public enum TypeofQueryColumn
    {
        Text,Date,DropDownList,Number
    }
    public class QueryColumn
    {
        public QueryColumn()
        {
            this.DataType = TypeofQueryColumn.Text;
        }
        
        public string Field
        {
            get;
            set;
        }
        public string Name
        {
            get;
            set;
        }
        public TypeofQueryColumn DataType
        {
            get;
            set;
        }
        string _CallBackAction;
        public string CallBackAction
        {
            get
            {
                if (_CallBackAction == null)
                {
                    UrlHelper helper = new UrlHelper(HttpContext.Current.Request.RequestContext);
                    if (this.DataType == TypeofQueryColumn.Date)
                        return helper.Action("QueryCalendarHtml", "Common");
                    if (this.DataType == TypeofQueryColumn.Text)
                        return helper.Action("QueryText", "Common");
                    if (this.DataType == TypeofQueryColumn.Number)
                        return helper.Action("QueryText", "Common");
                }

                return _CallBackAction;
            }

            set
            {
                _CallBackAction = value;
            }
        }
    }
}